package com.demo.entity;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "t_permission")
public class Permission {

	@Id  
    @GeneratedValue(strategy = GenerationType.IDENTITY)  
    private Integer id;  
	
	@Column(name = "token")
	private String token;  					//token
    
	@Column(name = "url")
	private String url;    					//资源url
    
	@Column(name = "description")
	private String description;  			//权限说明
    
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "t_role_permission",joinColumns = @JoinColumn(name = "permission_id"),
	inverseJoinColumns = @JoinColumn(name = "role_id"))
	@Fetch(FetchMode.SUBSELECT)
	private Set<Role> roles;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	
}
